<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<script type="text/javascript" src="static/My97DatePicker/WdatePicker.js"></script>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">知识库管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>知识库管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">知识关联查询管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">
		<div class="row mbl" >
			<div class="col-lg-12">
					<table style="width: 95%;margin-top: 20px;">
						<tr height="50">
							<td align="right" style="width: 100px;">省份&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="shengfen">
									<option value="">请选择</option>
									<?for(shengfen in shengfen_dictItem){?>
										<option value="${shengfen.value}">${shengfen.nameZh}</option>
									<?}?>
								</select>
							</td>
							<td align="right" style="width: 100px;">单位&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="danwei" name="danwei" /></td> 
							<td align="right" style="width: 100px;">姓名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="xingming" name="xingming" /></td> 
						</tr>
						<tr height="50">
							<td align="right" style="width: 100px;">手机&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="shouji" name="shouji" /></td> 
							<td align="right" style="width: 100px;">客户级别&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="kehujibie">
									<option value="">请选择</option>
									<?for(kehujibie in kehujibie_dictItem){?>
										<option value="${kehujibie.value}">${kehujibie.nameZh}</option>
									<?}?>
								</select>
							</td>
							<td align="right" style="width: 100px;">客户类别&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="kehuleibie">
									<option value="">请选择</option>
									<?for(kehuleibie in kehuleibie_dictItem){?>
										<option value="${kehuleibie.value}">${kehuleibie.nameZh}</option>
									<?}?>
								</select>
							</td>
						</tr>
						<tr height="50">
							<td align="right" style="width: 100px;">最后联系时间<br/>(start)&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 100%;" id="startTime" name="startTime" /></td> 
							<td align="right" style="width: 100px;">最后联系时间<br/>(end)&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 100%;" id="endTime" name="endTime" /></td>
							<?if(userid == 1){?>
								<td align="right" style="width: 100px;">创建人&nbsp;&nbsp;</td>
								<td>
									<select class="form-control" id="userId">
										<option value="">请选择</option>
										<?for(user in userList){
										if(user.id != 1){
										?>
											<option value="${user.id}">${user.nickname}</option>
										<?}}?>
									</select>
								</td>
							<?}else{?>
								<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
								<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
							<?}?>
						</tr>
						<tr height="50">
							<td align="right" style="width: 100px;">下次联系时间<br/>(start)&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 100%;" id="lastContactstartTime" name="lastContactstartTime" /></td> 
							<td align="right" style="width: 100px;">下次联系时间<br/>(end)&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 100%;" id="lastContactendTime" name="lastContactendTime" /></td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
							<td>
								<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo('1')">查询</button>
								<button type="button"  data-toggle="dropdown" class="btn btn-primary dropdown-toggle" onclick="deleteSearch()">清空筛选项</button>	
							</td>
						</tr>
					</table>
			</div>
		</div>

		<table
			class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th >序号</th>
					<th >单位</th>
					<th >姓名</th>
					<th >手机</th>
					<th >联系情况</th>
					<th >联系内容</th>
					<th >客户级别</th>
					<th >客户类别</th>
					<th >下次联系时间</th>
					<th >最后联系时间</th>
					<th >可操作</th>
				</tr>
			</thead>
			<tbody id="findUser">
			</tbody>
		</table>
		<div id="dataNull" class="panel-body" style="height: 90px; line-height: 50px;" align="center">
		</div>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var curr;
	function demo(curr) {
		$.ajax({
			type : "post",
			url : "searchRelevanceList.do",
			data : {
				"page" : curr || 1,
				"startTime" : $("#startTime").val(),
				"endTime" : $("#endTime").val(),
				"lastContactstartTime" : $("#lastContactstartTime").val(),
				"lastContactendTime" : $("#lastContactendTime").val(),
				"shengfen" : $("#shengfen").val(),
				"danwei" : $("#danwei").val(),
				"shouji" : $("#shouji").val(),
				"xingming" : $("#xingming").val(),
				"kehujibie" : $("#kehujibie").val(),
				"kehuleibie" : $("#kehuleibie").val(),
				"user" : $("#userId").val(),
			},
			dataType : "json",
			traditional : true,
			success : function(res) {
				//alert(JSON.stringify(res));
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(res[0].count > 0){
					$("#dataNull").html("");
				}else{
					$("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
				}
				for ( var i = 0; i < res[0].data.length; i++) {
					str += "<tr ondblclick=\"goknowledgeUpload('"+res[0].data[i].id+"')\"><td>"
							+ (i + 1)
							+ "</td><td>"
							+ res[0].data[i].danWei
							+ "</td><td>"
							+ res[0].data[i].xingMing
							+ "</td><td>"
							+ res[0].data[i].shouJi
							+ "</td><td>"
							+ res[0].data[i].lianXiQingQuang
							+ "</td><td>"
							+ res[0].data[i].lianXiNeiRong
							+ "</td><td>"
							+ res[0].data[i].keHuJiBie
							+ "</td><td>"
							+ res[0].data[i].keHuLeiBie
							+ "</td><td>"
							+ res[0].data[i].xiaCiLianXiShiJian
							+ "</td><td>"
							+ res[0].data[i].opCreateTime
							+ "</td><td>"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"goknowledgeUpload('"
							+ res[0].data[i].id
							+ "')\">"
							+ "查看"
							+ "</button>"
							+ "</td></tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res[0].page, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: res[0].page,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
							 var curr = obj.curr;
			                 curr=obj.curr;
						}
					}
				});
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	};
	//清空赛选项
	function deleteSearch(){
		 $("#startTime").val("");
		 $("#endTime").val("");
		 $("#lastContactstartTime").val("");
		 $("#lastContactendTime").val("");
		 $("#shengfen").val("");
		 $("#danwei").val("");
		 $("#shouji").val("");
		 $("#xingming").val("");
		 $("#kehujibie").val("");
		 $("#kehuleibie").val("");
		 $("#userId").val("");
	}
	//跳转至修改页
	function goknowledgeUpload(id){
		window.open("knowledge-edit-data-detail-update-relevance.html?id="+id+"&&classesEn=ke_hu_zi_liao&classesId=12&curr=1&searchType=1"); 
	}
	
	/*关联新闻栏目*/
	function categoryZTree(){
		layer.open({
			type : 2,
			area : [ '800px', '630px' ],
		    scrollbar: false,
		    shadeClose: true,
			fix : false, //不固定
			title : '栏目',
			//maxmin : true,  
			skin: 'layui-layer-rim', //加上边框
    	    btn : [ '保存 ', '关闭' ],
			content : ["cms-news-list-category-ztree.html",'no'],
			yes : function(index, layer) {
				 var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				 iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	}
	//审核
	function auditWord(auditStatus,curr){
		var value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		if(value != ''){
			$.ajax({
					type : "post",
					url : "auditStatus.do",
					dataType : "json",
					data:{
	   					"id":value,
	   					"status":auditStatus,
	   					"classesEn":"news"
					},
					traditional : true,
					beforeSend : function(XMLHttpRequest) {},
					success:function(data){
						if(data == 'yes'){
							 demo(curr);
							 layer.msg('操作成功！');
						}else{
							layer.msg('操作失败！');
						}
					},
					error:function(){
						alert("编辑失败");
					}
		
			})
			}else{
				layer.msg('请勾选内容！');
			}
	}
	//发布
	function publish(publishId){
		if (confirm("是否确认发布！！")){
			$.ajax({
					type : "post",
					url : "knowledgeEditDataPublish.do",
					dataType : "json",
					data:{
	      				"classesEn":"news",
	      				"id":publishId
					},
	   				beforeSend : function(XMLHttpRequest) {},
					success:function(res){
						if(res == 'yes'){
								demo(curr);
								layer.msg('发布成功！');
							}else{
								layer.msg('发布失败！');
							}
					},
					error:function(){
						alert("发布失败");
					}
		
			});
		}
	}
	//发布全部新闻
	function issueButton(){
		if (confirm("是否确认发布！建议总数量小于10万时使用.")){
			layer.msg('数据正在发布中，请稍候几分钟后在检索平台刷新页面获取最新数据。');
			$.ajax({
					type : "post",
					url : "knowledgeEditDataIssue.do",
					dataType : "json",
					data:{
	      				"classesEn":"news"
					},
	   				beforeSend : function(XMLHttpRequest) {},
					success:function(res){
						if(res == 'yes'){
								demo(curr);
								layer.msg('发布成功！');
							}else{
								layer.msg('发布失败！');
							}
					},
					error:function(){
						//alert("发布失败");
					}
		
			});
		}
	}
</script>